<?php

namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller;

class BaseController extends Controller
{
    protected static function responseMsg($message = "success"): \Illuminate\Http\JsonResponse
    {
        return self::responseJson(null, $message);
    }

    protected static function responseJson($data = null, $message = "success", $error = 0): \Illuminate\Http\JsonResponse
    {
        if ($message != "success" && !$error) {
            $error = 1;
        }

        return response()->json(["data" => $data, "message" => $message, "error" => $error]);
    }
}
